package com.mission.schedule.activity;

import android.Manifest;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;

import com.mission.schedule.R;
import com.mission.schedule.constants.Const;
import com.mission.schedule.constants.ShareFile;
import com.mission.schedule.cutimage.Crop;
import com.mission.schedule.utils.ActivityManager1;
import com.mission.schedule.utils.AfterPermissionGranted;
import com.mission.schedule.utils.EasyPermissions;
import com.mission.schedule.utils.PathFromUriUtils;
import com.mission.schedule.utils.PhotoActionHelper;
import com.mission.schedule.utils.SharedPrefUtil;
import com.mission.schedule.utils.Utils;

import java.io.File;
import java.util.List;

public class SetBackgroundMorenActivity extends BaseActivity implements
		OnClickListener{

	private LinearLayout top_ll_left,dbj_ll;
	private RelativeLayout nonebg_rl,item1_bg_rl,item2_bg_rl,item3_bg_rl,item4_bg_rl,item5_bg_rl,item6_bg_rl,item7_bg_rl,item8_bg_rl,selectlocal_rl;

	Context context;
	SharedPrefUtil sharedPrefUtil = null;
	String localpath = "",ismostimage = "", issjmostimage = "";
	Bitmap bitmap;
	ActivityManager1 activityManager = null;
	boolean permission  = false;
	int week_image = 1;

	String SKey = ShareFile.CUSTIOMMOSTIMAGE1;

	@Override
	protected void setListener() {
		top_ll_left.setOnClickListener(this);
		nonebg_rl.setOnClickListener(this);
		item1_bg_rl.setOnClickListener(this);
		item2_bg_rl.setOnClickListener(this);
		item3_bg_rl.setOnClickListener(this);
		item4_bg_rl.setOnClickListener(this);
		item5_bg_rl.setOnClickListener(this);
		item6_bg_rl.setOnClickListener(this);
		item7_bg_rl.setOnClickListener(this);
		item8_bg_rl.setOnClickListener(this);
	}

	@Override
	protected void setContentView() {
		setContentView(R.layout.activity_setbackground_moren);
	}

	@Override
	protected void onResume() {
		super.onResume();


	}

	@Override
	protected void init(Bundle savedInstanceState) {
		activityManager = ActivityManager1.getInstance();
		activityManager.addActivities(this);
		context = this;
		week_image = getIntent().getIntExtra("week_image",1);

		switch (week_image){
			case 1:
				SKey = ShareFile.CUSTIOMMOSTIMAGE1;
				break;
			case 2:
				SKey = ShareFile.CUSTIOMMOSTIMAGE2;
				break;
			case 3:
				SKey = ShareFile.CUSTIOMMOSTIMAGE3;
				break;
			case 4:
				SKey = ShareFile.CUSTIOMMOSTIMAGE4;
				break;
			case 5:
				SKey = ShareFile.CUSTIOMMOSTIMAGE5;
				break;
			case 6:
				SKey = ShareFile.CUSTIOMMOSTIMAGE6;
				break;
			case 7:
				SKey = ShareFile.CUSTIOMMOSTIMAGE7;
				break;
		}

		sharedPrefUtil = new SharedPrefUtil(context, ShareFile.USERFILE);

		item1_bg_rl = (RelativeLayout) findViewById(R.id.item1_bg_rl);
		item2_bg_rl = (RelativeLayout) findViewById(R.id.item2_bg_rl);
		item3_bg_rl = (RelativeLayout) findViewById(R.id.item3_bg_rl);
		item4_bg_rl = (RelativeLayout) findViewById(R.id.item4_bg_rl);
		item5_bg_rl = (RelativeLayout) findViewById(R.id.item5_bg_rl);
		item6_bg_rl = (RelativeLayout) findViewById(R.id.item6_bg_rl);
		item7_bg_rl = (RelativeLayout) findViewById(R.id.item7_bg_rl);
		item8_bg_rl = (RelativeLayout) findViewById(R.id.item8_bg_rl);


		nonebg_rl = (RelativeLayout) findViewById(R.id.nonebg_rl);
		selectlocal_rl = (RelativeLayout) findViewById(R.id.selectlocal_rl);

		top_ll_left = (LinearLayout) findViewById(R.id.top_ll_left);
		dbj_ll = (LinearLayout) findViewById(R.id.dbj_ll);

		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,getWindowManager().getDefaultDisplay().getWidth() - Utils.dipTopx(this,30));
		params.setMargins(0, Utils.dipTopx(this,15),0,0);
		dbj_ll.setLayoutParams(params);
		dbj_ll.setPadding(Utils.dipTopx(this,15),Utils.dipTopx(this,15),Utils.dipTopx(this,15),Utils.dipTopx(this,15));

	}


	@Override
	protected void setAdapter() {

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.top_ll_left:
			this.finish();
			break;
		case R.id.nonebg_rl:
			sharedPrefUtil.putString(context, ShareFile.USERFILE, SKey, "0");
			this.finish();
			break;
		case R.id.item1_bg_rl:
			sharedPrefUtil.putString(context, ShareFile.USERFILE, SKey, "a");
			this.finish();
			break;
		case R.id.item2_bg_rl:
			sharedPrefUtil.putString(context, ShareFile.USERFILE, SKey, "b");
			this.finish();
			break;
		case R.id.item3_bg_rl:
			sharedPrefUtil.putString(context, ShareFile.USERFILE, SKey, "c");
			this.finish();
			break;
		case R.id.item4_bg_rl:
			sharedPrefUtil.putString(context, ShareFile.USERFILE, SKey, "d");
			this.finish();
			break;
		case R.id.item5_bg_rl:
			sharedPrefUtil.putString(context, ShareFile.USERFILE, SKey, "e");
			this.finish();
			break;
		case R.id.item6_bg_rl:
			sharedPrefUtil.putString(context, ShareFile.USERFILE, SKey, "f");
			this.finish();
			break;
		case R.id.item7_bg_rl:
			sharedPrefUtil.putString(context, ShareFile.USERFILE, SKey, "g");
			this.finish();
			break;
		case R.id.item8_bg_rl:
			sharedPrefUtil.putString(context, ShareFile.USERFILE, SKey, "h");
			this.finish();
		default:
			break;
		}
	}


}
